<template>
  <div class="app-container">
    <el-tabs v-model="tabActiveName" type="card">
      <el-tab-pane label="日结/反日结" name="first">
        <div class="filter-container">
          <div class="left-block">
            <span>账户</span>
            <el-select v-model="searchDayForm.month" style="width: 70px" size="small" class="theme-select">
              <el-option v-for="(item, index) in $MONTH_LIST" :key="index" :label="item.label" :value="item.value"/>
            </el-select>
            <el-select v-model="searchDayForm.month" style="width: 70px" size="small" class="theme-select">
              <el-option v-for="(item, index) in $MONTH_LIST" :key="index" :label="item.label" :value="item.value"/>
            </el-select>
            <span>年</span>
          </div>
        </div>
        <div class="month-card-list">
          <div
            v-for="(item, index) in firstList"
            :class="{'month-card': true, green: true}"
            :key="index"
            @click="cardClickHandler(item)"
          >{{ item.month }}月</div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="月结/月日结" name="second">
        <div class="filter-container">
          <div class="left-block">
            <span>账户</span>
            <el-select v-model="searchMonthForm.month" style="width: 70px" size="small" class="theme-select">
              <el-option v-for="(item, index) in $MONTH_LIST" :key="index" :label="item.label" :value="item.value"/>
            </el-select>
            <el-select v-model="searchMonthForm.month" style="width: 70px" size="small" class="theme-select">
              <el-option v-for="(item, index) in $MONTH_LIST" :key="index" :label="item.label" :value="item.value"/>
            </el-select>
            <span>年</span>
          </div>
        </div>
        <div class="month-card-list">
          <div
            v-for="(item, index) in firstList"
            :class="{'month-card': true, blue: true}"
            :key="index"
            @click="cardClickHandler(item)"
          >{{ item.month }}月</div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
function createSearchForm(tar) {
  let raw = {
    keyword: '',
    month: '1'
  }
  if (tar) {
    raw = Object.assign(raw, tar)
  }
  return raw
}
export default {
  name: 'CashierMonthlyBalance',
  data() {
    const firstList = []
    const secondList = []
    for (let i = 0; i < 12; i++) {
      firstList.push({
        month: i + 1
      })
      secondList.push({
        month: i + 1
      })
    }
    return {
      tabActiveName: 'first',
      firstList,
      secondList,
      searchDayForm: createSearchForm(),
      searchMonthForm: createSearchForm()
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    cardClickHandler() {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        showClose: false
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .month-card-list {
    .month-card {
      display: inline-block;
      width: 80px;
      height: 80px;
      line-height: 80px;
      text-align: center;
      border-radius: 4px;
      color: rgb(120, 120, 120);
      background-color: rgb(230, 230, 230);
      margin-right: 10px;
      cursor: pointer;
      &:last-child{
        margin-right: 0;
      }
      &.blue {
        line-height: 78px;
        border: 1px solid rgb(26, 132, 232);
        color: rgb(26, 132, 232);
        background-color: rgb(228, 238, 248);
      }
      &.green {
        line-height: 78px;
        border: 1px solid rgb(33, 167, 105);
        color: rgb(33, 167, 105);
        background-color: rgb(225, 236, 232);
      }
    }
  }
</style>
